<template>
  <div class="my">
    <div class="wrapper">
      <!-- 头部 star  -->
      <div class="head">
        <router-link tag="div" to="/setup" class="head_left">
          <img :src="require('../assets/img/Hb.png')" alt="" />
        </router-link>
        <div class="head_right">
          <img :src="require('../assets/img/4H.png')" alt="" />
        </div>
      </div>
      <!-- 头部 end  -->

      <!-- 用户信息 star -->
      <div class="user" v-show="flag">
        <div class="tou">
          <img :src="require('../assets/img/UK.png')" alt="" />
        </div>
        <div class="information">
          <p>wyRLywLiqiqP</p>
          <p>{{username}}</p>
          <p>普通会员</p>
        </div>
      </div>
      <div class="loging" v-show="!flag">
        <router-link tag="button" to="/login">登录</router-link>
      </div>
      <!-- 用户信息 end -->

      <!-- 用户积分 star  -->
      <div class="integral">
        <ul>
          <li>
            <a href="">
              <p>0</p>
              <p>旅游卡</p>
            </a>
          </li>
          <li>
            <a href="">
              <p>0</p>
              <p>积分</p>
            </a>
          </li>
          <li>
            <a href="">
              <p>0</p>
              <p>现金券</p>
            </a>
          </li>
        </ul>
      </div>
      <!-- 用户积分 end  -->

      <!-- 订单 star  -->
      <div class="order">
        <h3>订单</h3>
        <div class="main">
          <ul>
            <li v-for="item in lists" :key="item.title">
              <a  @click="goder(item.title)">
                <div class="img">
                  <img :src="item.img" alt="" />
                </div>
                <p>{{item.title}}</p>
              </a>
            </li>
          </ul>
        </div>
      </div>
      <!-- 订单 end  -->

      <!-- 常用 star  -->
      <div class="common">
        <h3>常用</h3>
        <div class="main">
          <ul>
            <li>
              <a href="">
                <div class="img">
                  <img :src="require('../assets/img/wt.png')" alt="" />
                </div>
                <p>会员中心</p>
              </a>
            </li>
            <li>
              <router-link tag="a" to="/MyComments">
                <div class="img">
                  <img :src="require('../assets/img/0Y1.png')" alt="" />
                </div>
                <p>我的评价</p>
              </router-link>
            </li>
            <li>
              <router-link tag="a" to="/collection" >
                <div class="img">
                  <img :src="require('../assets/img/uS.png')" alt="" />
                </div>
                <p>我的收藏</p>
              </router-link>
            </li>
            <li>
              <a href="">
                <div class="img">
                  <img :src="require('../assets/img/O9.png')" alt="" />
                </div>
                <p>我的发票</p>
              </a>
            </li>
            <li>
              <a href="">
                <div class="img">
                  <img :src="require('../assets/img/og.png')" alt="" />
                </div>
                <p>常用信息</p>
              </a>
            </li>
            <li>
              <a href="">
                <div class="img">
                  <img :src="require('../assets/img/ji.png')" alt="" />
                </div>
                <p>意见反馈</p>
              </a>
            </li>
            <li>
              <a href="">
                <div class="img">
                  <img :src="require('../assets/img/kU.png')" alt="" />
                </div>
                <p>联系客服</p>
              </a>
            </li>
          </ul>
        </div>
      </div>
      <!-- 常用 end  -->
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: false,
      username:"",
      lists:[
        {
          img:require("../assets/img/D01.png"),
          title:"我的订单",
        },
        {
          img:require("../assets/img/-Q1.png"),
          title:"抢购订单",
        },
        {
          img:require("../assets/img/-U.png"),
          title:"拼团订单",
        },
        {
          img:require("../assets/img/XH.png"),
          title:"保险订单",
        },
      ]
    };
    
  },
  methods:{
    goder(title){
      this.$router.push("/myorder?title="+title)
    }
  },
  created() {
    let token = window.localStorage.getItem("token");
    if (token) {
      //判断是否存在token，不存在显示登录，存在显示用户信息
      this.flag = true;
      this.username = token;
    } else {
      this.flag = false;
    }
  },
};
</script>

<style lang="scss" scoped>
.my {
  background-color: #f0eee2;
  .wrapper {
    min-width: 320px;
    max-width: 750px;
    margin: 0 auto;
    padding-bottom: 60px;
  }
  .head {
    height: 65px;
    background: url(../assets/img/2E1.png) no-repeat;
    background-size: 100% 65px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    img {
      width: 30px;
      height: 30px;
    }
  }
  .user {
    display: flex;
    padding: 40px;
    background-color: #fff;
    .tou {
      img {
        width: 80px;
      }
    }
    .information {
      padding-left: 20px;
      p {
        &:nth-child(1) {
          font-weight: bold;
          font-size: 18px;
          color: rgb(58, 54, 50);
        }
        &:nth-child(2) {
          color: #999;
          font-size: 15px;
          line-height: 26px;
        }
        &:nth-child(3) {
          background: url(../assets/img/_F.png) no-repeat;
          height: 20px;
          line-height: 20px;
          width: 52px;
          background-size: 100% 20px;
          font-size: 10px;
          padding-left: 22px;
          color: #fff;
        }
      }
    }
  }
  .loging {
    padding: 40px;
    background-color: #fff;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    button {
      width: 150px;
      height: 40px;
      border: 1px solid #ccc;
      background-color: #f0eee2;
      color: rgb(86, 70, 55);
    }
  }
  /* .user .tou{} */
  .integral {
    background-color: #fff;
    padding-bottom: 20px;
    ul {
      display: flex;
      li {
        width: 33%;
        text-align: center;
        a {
          color: rgb(58, 54, 50);
          p {
            &:nth-child(1) {
              font-weight: bold;
            }
            &:nth-child(2) {
              font-size: 14px;
              color: #999;
            }
          }
        }
      }
    }
  }
  .order,
  .common {
    margin: 16px 20px 0;
    background-color: #fff;
  }
  .order h3,
  .common h3 {
    font-weight: normal;
    padding-left: 20px;
    font-size: 16px;
    margin: 0;
    line-height: 50px;
    border-bottom: 1px solid rgb(251, 246, 233);
    color: rgb(58, 54, 50);
  }
  .order .main ul,
  .common .main ul {
    display: flex;
    flex-wrap: wrap;
  }
  .order {
    .main {
      ul {
        li {
          width: 25%;
          padding: 20px 0;
          text-align: center;
        }
      }
    }
  }
  .order .main ul li a,
  .common .main ul li a {
    color: rgb(148, 130, 111);
  }

  .order .main ul li img,
  .common .main ul li img {
    width: 30px;
    margin: 0 auto;
  }
  .order .main ul li a p,
  .common .main ul li a p {
    font-size: 14px;
    line-height: 30px;
  }
  .common {
    .main {
      ul {
        li {
          width: 33%;
          padding: 20px 0;
          text-align: center;
        }
      }
    }
  }
}
</style>